package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.*;
import com.ssy.lingxi.system.dto.response.CountryAreaListResponse;
import com.ssy.lingxi.system.entity.CountryArea;
import com.ssy.lingxi.system.service.CountryAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;
/**
* @menu 基础设置-国家设置管理
* @tag shit
* @author wrc
* @date 2020/7/20
*/
@Api(tags = "基础设置国家设置管理")
@RestController
public class CountryAreaController {


    @Autowired
    CountryAreaService countryAreaService;

    @ApiOperation(value = " 查询国家设置列表")
    @GetMapping("/country/list")
    public Wrapper<PageData<CountryAreaListResponse>> countryAreaList(CountryAreaListRequest request) {
        return countryAreaService.countryAreaList(request);
    }

    @ApiOperation(value = " 新增国家")
    @PostMapping("/country/add")
    public Wrapper countryAreaAdd(@RequestBody @Valid CountryAreaAddRequest request,HttpServletRequest httpServletRequest) {
        return countryAreaService.countryAreaAdd(httpServletRequest,request);
    }

    @ApiOperation(value = " 删除国家")
    @PostMapping("/country/delete")
    public Wrapper countryAreaDelete(@RequestBody CountryAreaDeleteRequest request) {
        return countryAreaService.countryAreaDelete(request);
    }



    @ApiOperation(value = "修改国家")
    @PostMapping("/country/update")
    public Wrapper countryAreaUpdate( @RequestBody @Valid CountryAreaUpdateRequest request) {
        return countryAreaService.countryAreaUpdate(request);
    }



    @ApiOperation(value = " 查询国家详情")
    @GetMapping("/country/details")
    public Wrapper<CountryAreaListResponse> countryAreaDetails(CountryAreaDetailsRequest request) {
        return countryAreaService.countryAreaDetails(request);
    }


    @ApiOperation(value = " 查询所有国家设置")
    @GetMapping("/country/all")
    public Wrapper<List<CountryArea>> countryAreaAll() {
        return countryAreaService.countryAreaAll();
    }


    @ApiOperation(value = "停用&启用国家")
    @PostMapping("/country/update/state")
    public Wrapper countryAreaStop(@RequestBody CountryAreaStopRequest request) {
        return countryAreaService.countryAreaStop(request);
    }


}
